import { serializeParams } from "@masx200/search-hash-params-router";

export function getactivecondition(e: HTMLAnchorElement, path: string) {
    let activecondition: boolean;
    if (process.env.PRERENDER) {
        activecondition =
            (e.hash.length < 1 &&
                location.pathname.length > 0 &&
                e.pathname === "/" + serializeParams({ md: path })) ||
            (location.hash.length > 1 && e.hash === location.hash);
    } else {
        activecondition =
            e.hash === "#" + path ||
            e.hash === "#" + serializeParams({ md: path }) ||
            (location.hash.length > 1 && e.hash === location.hash);
    }
    return activecondition;
}
